package com.jingdianjichi.subject.application.controller;

import com.jingdianjichi.subject.common.entity.PageResult;
import com.jingdianjichi.subject.infra.basic.entity.SubjectInfoEs;
import com.jingdianjichi.subject.infra.basic.service.SubjectEsService;
import com.jingdianjichi.subject.infra.entity.UserInfo;
import com.jingdianjichi.subject.infra.rpc.UserRpc;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Description: 测试FeignController
 * Copyright: Copyright (c) 2024
 * Create Time: 2024-07-28 10:44
 *
 * @author wanglianyun
 */
@RestController
@RequestMapping("/subject/category")
@Slf4j
public class TestFeignController {

    @Resource
    private UserRpc userRpc;

    @Resource
    private SubjectEsService subjectEsService;

    @GetMapping("testFeign")
    public void testFeign() {
        UserInfo userInfo = userRpc.getUserInfo("jichi");
        log.info("testFeign.userInfo:{}", userInfo);
    }

//    @GetMapping("createIndex")
//    public void testCreateIndex() {
//        subjectEsService.createIndex();
//    }
//
//    @GetMapping("addDocs")
//    public void testAddDocs() {
//        subjectEsService.addDoc();
//    }
//
//    @GetMapping("find")
//    public void testFind() {
//        subjectEsService.find();
//    }
//
//    @GetMapping("search")
//    public void testSearch() {
//        subjectEsService.search();
//    }

    @PostMapping("querySubjectByKeyword")
    public void testQuerySubjectByKeyword() {
        SubjectInfoEs subjectInfoEs = new SubjectInfoEs();
        subjectInfoEs.setKeyWord("mysql");
        PageResult<SubjectInfoEs> subjectInfoEsPageResult = subjectEsService.querySubjectList(subjectInfoEs);
        log.info("querySubjectByKeyword:{}", subjectInfoEsPageResult);
    }

}
